package org.eclipse.epsilon.emc.iModelTest;
import java.util.ArrayList;

import org.eclipse.epsilon.eol.EolModule;
import org.eclipse.epsilon.emc.rdbms.dbConnection.SQL2012Connection;
import org.eclipse.epsilon.emc.rdbms.dbConnection.H2Connection;
import org.eclipse.epsilon.emc.rdbms.iModel.DBReflexiveModel;
import org.eclipse.epsilon.emc.rdbms.iModel.DBReflexiveModelElement;

public class TestH2
{  
public static void main(String[] args) throws Exception 
{ 
   DBReflexiveModel rModel = new DBReflexiveModel();  //Create a new model.
   rModel.setName("epsilon"); //Set the Model Name
   rModel.load(); //Load the model
   EolModule module = new EolModule(); //Create a new EOL Module.

   
   /********************************************************
    **  For Test Purposes Only
    **  Not needed in final version.                       
    *********************************************************/
   H2Connection con = new H2Connection("jdbc:h2:","~","epsilon"); //Create a new connection object to the H2 database  
   con.db_setup("C:\\config.sql"); //Used to initialise the database schema so we have a static test bed.
   
   /********************************************************
   **  For Test Purposes Only
   **  Build up a dummy epsilon program                       
   *********************************************************/
   //Create a simple dummy epsilon program that will use the model we have just created.
   
   String modelString = ""; //Initialise the modelString
   //module.parse("A.all.println(); var a = new A; a.type='bar'; a.type.println(); A.all.println();");
   // modelString = "EPSILON_TEST_1.all.println()";   //This prints out the values for the table.
   //modelString = "EPSILON_TEST_1.all.println(); var a = new EPSILON_TEST_1;EPSILON_TEST_1.all.println(); ";//Add new row to db
   modelString = "var a  = new EPSILON_TEST_1; a.type='test';";
   //modelString = "EPSILON_TEST_1.type.println();";
   //modelString = modelString.concat(arrTables.get(i).toString().concat(""));			
   /********************************************************
   **  End Of test Code....
   **  
   *********************************************************/
   module.parse(modelString); 
   module.getContext().getModelRepository().addModel(rModel);
   module.execute();
 }
}



